<template>
	<view>
		<text>{{ $t('tabBar.reportText') }}</text>
		<text>功能开发中...</text>

		<upgrade-center ref="upgradeCenter" theme="blue" url="/api/mobile/checkUpgrade" :autoCheck="false"></upgrade-center>
		<view style="margin-top: 80rpx;" />
	</view>
</template>

<script>
	import UpgradeCenter from '@/components/upgrade-center-app/upgrade.vue';
  import { handleScan } from '@/logics/scanHandler';
	import { useScan } from "@/utils/scan-code";
	const { scan } = useScan();
	export default {
		components: {
			UpgradeCenter
		},
		data() {
			return {

			};
		},
		onShow() {
			const that = this;
			// 导航栏多语言
			uni.setNavigationBarTitle({
				title: that.$t('pages.sys.report.reportText')
			});
			// 监听扫描
			scan.start(async(res) => {
				// console.log('扫描结果', res);
				await handleScan(res);
			});
		},
		destroyed: function(){
			// uni.showModal({
			//     title: 'destroyed',
			//     content: '停止监听扫描'
			// });
			// 页面退出时一定要停止监听扫描,否则监听将一直有效
			scan.stop();
		},
    onNavigationBarButtonTap(e) {
      const that = this;
      // console.log("点击了自定义按钮", e);
      if (e.index === 0) {
        uni.scanCode({
          success: async function(res) {
            // console.log('类型', res.scanType);
            // console.log('内容', res.result);
            await handleScan({
              data: res.result
            });
          }
        });
      }
    },
		methods: {

		}
	}
</script>

<style>

</style>
